<?php
//echo 'tes aja'; exit;
    //QUERY 1
    foreach ($getDetail as $h) {
        $hId   			= $h["REQ_ID"];
    	$hDate   		= $h["REQ_DATE"];
    	$hDescription   = $h["REQ_DESCRIPTION"];
    	$hNik   		= $h["REQ_NIK"];
    	$hUntukNik   	= $h["REQ_UNTUK_NIK"];
    	$hAtasankNik   	= $h["REQ_ATASAN_NIK"];
    	$hAtasankName	= $h["ATASANNAME"];
    	$hReqInfoHrd= $h["REQ_INFO_HRD"];
    	$hReqFloor		= $h["REQ_FLOOR"];
    	$hReqRbfId		= $h["REQ_RBF_ID"];
        
        $hNikName=$h['NIKNAME'];
        $hNikOrg=$h['NIKORG'];
        $hNikJobPosition=$h['NIKJOBPOSITION'];
    }
    if(empty($cRequestNo) && !empty($pReqForNik)){
        echo "Andi Siswanto";
    	//$cNik				= $pReqForNik;
    	//$cName  			= dbora_getname("$pReqForNik");
    	//$cOrg  				= dbora_getorg("$pReqForNik");
    	//$cJob  				= dbora_getjobposition("$pReqForNik");
    }else{
    	$cNik				= $hUntukNik ;
    	$cName  			= $hNikName;
    	$cOrg  				= $hNikOrg;
    	$cJob  				= $hNikJobPosition;
    }
    
    //QUERY 2
    foreach($getDetail2 as $a){
        $aParkirdNik  		= $a["PARKIRD_NIK"];
    	$aParkirdUntukNik  	= $a["PARKIRD_UNTUK_NIK"];
    	$aParkirdAtasanNik  = $a["PARKIRD_ATASAN_NIK"];
    	$aParkirdType  		= $a["PARKIRD_TYPE"];
    	$aParkirdPlat  		= $a["PARKIRD_PLAT"];
    	$aParkirdStnk  		= $a["PARKIRD_STNK"];
    	$aParkirdDate  		= $a["PARKIRD_DATE"];
    	$aParkirdDescription= $a["PARKIRD_DESCRIPTION"];
    	$aParkirdFile  		= $a["PARKIRD_FILE"];
    	$aParkirdUseBy  	= $a["PARKIRD_USE_BY"];
    	$aParkirdType1  	= $a["PARKIRD_TYPE_1"];
    	$aParkirdPlat1  	= $a["PARKIRD_PLAT_1"];
    	$aParkirdStnk1  	= $a["PARKIRD_STNK_1"];
    	$aParkirdFlag1  	= $a["PARKIRD_FLAG_1"];
    	$aParkirdType2  	= $a["PARKIRD_TYPE_2"];
    	$aParkirdPlat2  	= $a["PARKIRD_PLAT_2"];
    	$aParkirdStnk2  	= $a["PARKIRD_STNK_2"];
    	$aParkirdFlag2  	= $a["PARKIRD_FLAG_2"];
    	$aParkirdType3  	= $a["PARKIRD_TYPE_3"];
    	$aParkirdPlat3  	= $a["PARKIRD_PLAT_3"];
    	$aParkirdStnk3  	= $a["PARKIRD_STNK_3"];
    	$aParkirdFlag3  	= $a["PARKIRD_FLAG_3"];
    	$aParkirdType4  	= $a["PARKIRD_TYPE_4"];
    	$aParkirdPlat4  	= $a["PARKIRD_PLAT_4"];
    	$aParkirdStnk4  	= $a["PARKIRD_STNK_4"];
    	$aParkirdFlag4  	= $a["PARKIRD_FLAG_4"];
    	$aContractSdate  	= $a["CONTRACT_SDATE"];
    	$aContractEdate  	= $a["CONTRACT_EDATE"];
    }
    
    //QUERY 3
    foreach($getDetail3 as $k){
        $kCtrlId   			= $k["CTRL_ID"];
    	if(!empty($kCtrlId)){
    	   $vCardFlag = "selected";
    	}
    }
    
    //QUERY 4
    foreach($getDetail4 as $l){
        $lExt   			= $l["TELP_EXT_EXT_TYPE"];
    	$TelpExtNo   		= $l["TELP_EXT_NO"];
    	$TelpExtEmail   	= $l["TELP_EXT_EMAIL"];
    	$CrtlTelpId   		= $l["CRTL_TELP_ID"];
    
    	$tempvar    = split(",",$lExt);
    	$vLOKAL  	= $tempvar[0];
    	$vSLJJ 		= $tempvar[1];
    	$vSLI 		= $tempvar[2];
    
    	if(!empty($vLOKAL)){
    		$lokal = "checked";
    	}else{
    		$lokal = "";
    	}
    
    	if(!empty($vSLI)){
    		$sli = "checked";
    	}else{
    		$sli = "";
    	}
    
    	if(!empty($vSLJJ)){
    		$sljj = "checked";
    	}else{
    		$sljj = "";
    	}
    }
    
    //QUERY 5
    $arr_ri_name = array();
    foreach($getDetail5 as $a){
        $arr_ri_name[] = $a["RI_NAME"];
    }
    
    //QUERY 6 & 7
    if(!empty($cRequestNo)){
        foreach($getDetail6 as $z){
            $zFloor = $z["MST_FLOOR_DESC"];
        }
        foreach($getDetail7 as $y){
            $yRbfId = $y["RBF_ROOM"];
        }
    }
    
?>

<script>
    function cancel() {
        $.post("<?= site_url() ?>search_global", function(data) {
            window.location = '<?php echo base_url(); ?>search_global';
        });
    }
    function closeSrnKrjReqSave() {
        $radioChecked='';
        if (document.getElementById("pApprovalY").checked == true){
            $radioChecked = "Y"; 
        }
        else{
            $radioChecked = "N";
        }
        
        $.post("<?= site_url() ?>search_global/closing_reqSave", {
            pCtrlID: $('#pCtrlID').val(),
            pCType: $('#pCType').val(),
            pApproval: $radioChecked 
            //pComment: $('#pComment').val(),
            //pAccesNo: $('#pAccesNo').val()
        },
        function(data) {
            window.location = '<?php echo base_url(); ?>search_global';
        }
        );
    }
</script>


<form id="formarea" role="form" method="post" action="#">
<input type="hidden" value="<?php echo $cRequestNo; ?>" id="pCtrlID" />
<input type="hidden" value="<?php echo $cType; ?>" id="pCType" />
<div class="col-md-offset-0" id="top">
    <div class="col-md-11">
        <div class="panel panel-default">
			<div class="panel-heading">
			<h4 class="panel-title"><b> User Login </b></h4>
			</div>
			<div class="panel-body">
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">NIK</label>
    						<div class="col-md-9"><?php echo $sesNik;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Nama</label>
    						<div class="col-md-9"><?php echo $sesName;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Departemen</label>
    						<div class="col-md-9"><?php echo $sesOrg;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Position</label>
    						<div class="col-md-9"><?php echo $sesJob;?></div>
				        </div>
                    </div>                   
                </div>
                
            </div>
        </div>
        
        <div class="panel panel-default">
			<div class="panel-heading">
			<h4 class="panel-title"><b> Requestor </b></h4>
			</div>
			<div class="panel-body">
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Nik</label>
    						<div class="col-md-9"><?php echo $cNik;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Nama</label>
    						<div class="col-md-9"><?php echo $cName;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Departemen</label>
    						<div class="col-md-9"><?php echo $cOrg;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Job Position</label>
    						<div class="col-md-9"><?php echo $cJob;?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Request Description</label>
    						<div class="col-md-9"><?php echo nl2br($hDescription);?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Informasi HRD</label>
    						<div class="col-md-9"><?php echo nl2br($hReqInfoHrd);?></div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Nama Atasan</label>
    						<div class="col-md-9"><?php echo $hAtasankName;?></div>
				        </div>
                    </div>                   
                </div>
                
                  
                
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3">Closing Order</label>
    						<div class="col-md-9">
                            <input type="radio" name="radioApp" id="pApprovalY" value="Y"/>Yes
                            <input type="radio" name="radioApp" id="pApprovalN" value="N" checked=""/>No
                            </div>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3"></label>
				        </div>
                    </div>                   
                </div>
                <div class="row"> 
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="control-label col-md-3"></label>
    						<div class="col-sm-2">
                                <button type="button" class="btn btn-primary btn-block" onclick="closeSrnKrjReqSave();">Submit</button>
                            </div>
                            <div class="col-sm-2">
                                <button type="button" class="btn btn-default btn-block" onclick="cancel();" >Cancel</button>
                            </div>
				        </div>
                    </div>                   
                </div>
            </div>
        </div>
    
    </div>
</div>
</form>